<!--
 * @Date: 2024-09-27 09:03:53
 * @Author: LiSong
 * @LastEditors: LiSong
 * @LastEditTime: 2024-09-27 09:49:14
 * @Description: 
-->
<template>
  <template class="" v-if="!!widgetList && widgetList.length > 0">
    <template v-for="(subWidget, swIdx) in widgetList" :key="swIdx">
      <!-- 布局部件 -->
      <template v-if="'container' === subWidget.category">
        <component
          :is="getComponentByContainer(subWidget)"
          :key="subWidget.id"
          :widget="subWidget"
          :designer="null"
          :parent-list="widgetList"
          :parent-widget="widget"
          :index-of-parent-list="swIdx"
          :class="[
            'form-widget-item', `${subWidget.type}-item`, mark ? `${mark}__area` : ''
          ]"
        >
          <!-- 递归传递插槽！！！ -->
          <template v-for="slot in Object.keys($slots)" v-slot:[slot]="scope">
            <slot :name="slot" v-bind="scope"></slot>
          </template>
        </component>
      </template>
      <!-- 字段部件 -->
      <template v-else>
        <component
          :is="`${subWidget.type}-widget`"
          :key="subWidget.id"
          :field="subWidget"
          :designer="null"
          :parent-list="widgetList"
          :design-state="false"
          :parent-widget="widget"
          :index-of-parent-list="swIdx"
          :class="[
            'form-widget-item', `${subWidget.type}-item`, mark ? `${mark}__area` : ''
          ]"
        >
          <!-- 递归传递插槽！！！ -->
          <template v-for="slot in Object.keys($slots)" v-slot:[slot]="scope">
            <slot :name="slot" v-bind="scope"></slot>
          </template>
        </component>
      </template>
    </template>
  </template>
  
</template>

<script>
import emitter from '@/utils/emitter'
import refMixin from "@/components/form-render/refMixin"
import containerItemMixin from "@/components/form-render/container-item/containerItemMixin"

import FieldComponents from '@/components/form-designer/form-widget/field-widget/index'

export default {
  name: 'RkLayoutComp',
  props: {
    mark: String,
    widget: Object,
    widgetList: Array,
  },
  mixins: [emitter, refMixin, containerItemMixin],
  inject: ['refList', 'sfRefList', 'globalModel'],
  components: {
    ...FieldComponents
  }
}
</script>

<style lang="scss" scoped>

</style>
